#ifndef CCL_H
#define CCL_H

//---STD-------------------------------------------------------------
#include<iostream>
#include <stdlib.h>
#include<fstream>
#include<assert.h>
#include<math.h>
#include <algorithm>
#include <string>

//---CL--------------------------------------------------------------
#ifdef _MACOSX
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif

//---Using-----------------------------------------------------------
using std::string;
using std::ostream;

//-------------------------------------------------------------------
namespace SCL {

class CCL
{
private:


    cl_device_id* Devices;   // list of devices
    cl_ulong MemGpu;         // size of the gpu memory
    cl_ulong MemLoc;         // size of the local memory
    cl_uint NbProcs;         // nb of compute units
    size_t NbWorksMax;       // max nb of work items in a group
    size_t NbWorks;          // actual nb of work items in a group
    size_t NbGlobal;         // nb of total work items
    //cl_uint NbUnits;       // nb of work items in a group
    cl_uint NbPlatforms;     // nb of platforms (in general =1)
    cl_context Context;      // opencl context
    cl_uint NbDevices;       // number of devices of the gpu (in general 1)
    cl_uint numdev;          // device number (in general=0)
    cl_device_type DeviceType;       // device type  (cpu ou gpu)
    cl_command_queue CommandQueue;   // file de commandes




    cl_program Program;              // compute program
    cl_kernel Kernel,Update,Iter;    // compute kernels


    cl_mem wa_gpu;       // balance variables stored on the gpu
    cl_mem wb_gpu;       // balance variables stored on the gpu
    cl_mem iter_gpu;     // iteration counter on the gpu


#include "param.h"



    cl_float wa[_N];              // variables conservatives dans les vf
    cl_float wb[_N];              // variables conservatives dans les vf
    cl_float waverif[_N];              // variables conservatives dans les vf
    cl_float wbverif[_N];              // variables conservatives dans les vf

    cl_float t;
    cl_uint iter;  // numero de l'iteration
    cl_mem t_gpu;  // temps courant

public:
    CCL();
    ~CCL();

    // prepare the memory and the kernels
    void InitKernel();

    // computations
    void Compute();

    // display
    void display();

};

}
#endif // CCL_H
